package charts;





import java.sql.SQLException;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;


public class PieChart extends JFrame{

    DefaultPieDataset dataset;//Dataset qui va contenir les Données
    JFreeChart graphe;        //Graphe
    ChartPanel cp;            //Panel


    public PieChart() {
        dataset = new DefaultPieDataset();
//Statique
        dataset.setValue("Java",new Double(60.0) );
        dataset.setValue("BD",new Double(20.0) );
        dataset.setValue("Maths",new Double(80.0) );
 //*Connexion récupération des données
//        Double d;
//        String ch;
//        try {
//            Connexion.rs = Connexion.st.executeQuery("select * from etudiant");
//            while (Connexion.rs.next()) {
//
//                d = Connexion.rs.getDouble(1);
//                ch = Connexion.rs.getString(2);
//                //System.out.println("" + d);
//                //System.out.println("" + ch);
//
//                dataset.setValue(ch, d);//remplissage dataset
//            }
//
//        } catch (SQLException ex) {
//            System.out.println("...");
//        }
        graphe = ChartFactory.
                createPieChart("Exemple Camemberg", dataset,true ,true ,false);

        cp = new ChartPanel(graphe);
        this.add(cp);
    }


    public static void main (String args[]){
    Connexion con = new Connexion();
        PieChart pchart = new PieChart();
        pchart.setVisible(true);

    }
}
